| Conditions | 7 |
| Total Lines | 30 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /* global variationSimulatorData */ |
||
| 8 | function updateSimulator() |
||
| 9 | { |
||
| 10 | if (window.WCSimulatorId !== '') |
||
|
|
|||
| 11 | { |
||
| 12 | var updateSelector = variationSimulatorData.variationSelector; |
||
| 13 | if (updateSelector === 'default') { |
||
| 14 | updateSelector = 'div.woocommerce-variation-price span.price span.woocommerce-Price-amount'; |
||
| 15 | } |
||
| 16 | |||
| 17 | var productType = variationSimulatorData.productType; |
||
| 18 | |||
| 19 | if (productType !=='variable') |
||
| 20 | { |
||
| 21 | clearInterval(window.variationInterval); |
||
| 22 | } |
||
| 23 | else |
||
| 24 | { |
||
| 25 | var priceDOM = document.querySelector(updateSelector); |
||
| 26 | if (priceDOM != null) { |
||
| 27 | var newPrice = priceDOM.innerText; |
||
| 28 | if (newPrice !== window.lastPrice) { |
||
| 29 | window.lastPrice = newPrice; |
||
| 30 | window.pgSDK.simulator.update(window.WCSimulatorId, {itemAmountSelector: updateSelector}) |
||
| 31 | } |
||
| 32 | } else { |
||
| 33 | return false; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | window.variationInterval = setInterval(function () { |
||
| 40 | }, 5000); |
This check looks for functions where a
returnstatement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBigwill only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined.This behaviour may not be what you had intended. In any case, you can add a
return undefinedto the other execution path to make the return value explicit.